package com.test.chapter2;

import java.io.IOException;

import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.FileInputFormat;
import org.apache.hadoop.mapred.FileOutputFormat;
import org.apache.hadoop.mapred.JobClient;
import org.apache.hadoop.mapred.JobConf;


public class App {

	public static void main(String[] args) throws IOException {
		
		if(args.length != 2)
		{
			System.err.println("Usage:App [input path] [putput path] ");
			System.exit(-1);
		}
		
		JobConf conf = new JobConf(App.class);
		conf.setJobName("Max Temperature ");
		
		FileInputFormat.addInputPath(conf, new Path(args[0]));
		FileOutputFormat.setOutputPath(conf, new Path(args[1]));
		
		conf.setMapperClass(MaxTemperatureMapper.class);
		conf.setReducerClass(MaxTemperatureReducer.class);
		//添加combiner,在map处理以后,发送到reduce之前,先做本地的比较,减少网络中的数据传输量
		conf.setCombinerClass(MaxTemperatureCombiner.class);
		
		
		conf.setOutputKeyClass(Text.class);
		conf.setOutputValueClass(IntWritable.class);
		
		JobClient.runJob(conf);

	}

}
